﻿/**
 * ...
 * @author Lobanov A.V.
 */

package view
{
	import model.StageProxy;
	import model.utils.DataXmlContainer;
	import model.utils.DataXmlLoader;
	import view.module.BackgroundMediator;
	import view.module.ContactsMediator;
	import view.module.MainMenuMediator;
	import view.module.PortfolioMediator;
	
	import org.puremvc.as3.interfaces.IMediator;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;
	
	import view.module.FooterMediator;
	import model.utils.*;
	import view.components.utils.UIEvent;
	
	/**
	 * A Mediator for interacting with the ...
	 */
	public class ApplicationMediator extends Mediator implements IMediator 
	{
		
		// Cannonical name of the Mediator
		public static const NAME:String = "ApplicationMediator";
		
		// StageProxy for our view module
		private var _stageProxy:StageProxy;
		
		public function ApplicationMediator( viewComponent:Object ) 
		{
			// pass the viewComponent to the superclass where 
			// it will be stored in the inherited viewComponent property
			super( NAME, viewComponent );
			_stageProxy = facade.retrieveProxy(StageProxy.NAME) as StageProxy;
			
			initializeModules();
		}
		
		private function initializeModules() : void 
		{		
			//trace("init modules");
			
			//init modul
			facade.registerMediator( new BackgroundMediator(_stageProxy.getLayer(StageProxy.MAIN_BG)) );
			facade.registerMediator( new FooterMediator(_stageProxy.getLayer(StageProxy.FOOTER)) );
			facade.registerMediator( new MainMenuMediator(_stageProxy.getLayer(StageProxy.MAIN_MENU)) );
			//facade.registerMediator( new ContactsMediator(_stageProxy.getLayer(StageProxy.CONTACTS)) );
			facade.registerMediator( new PortfolioMediator(_stageProxy.getLayer(StageProxy.PORTFOLIO)) );
			
			//loading static data
			sendNotification( ApplicationFacade.LOAD_STATIC_DATA, null );
		}
        
		/**
		 * List all notifications this Mediator is interested in.
		 * <P>
		 * Automatically called by the framework when the mediator
		 * is registered with the view.</P>
		 * 
		 * @return Array the list of Nofitication names
		 */
		override public function listNotificationInterests():Array 
		{
			return [];
		}
		
		/**
		 * Handle all notifications this Mediator is interested in.
		 * <P>
		 * Called by the framework when a notification is sent that
		 * this mediator expressed an interest in when registered
		 * (see <code>listNotificationInterests</code>.</P>
		 * 
		 * @param INotification a notification 
		 */
		override public function handleNotification( note:INotification ):void 
		{
			switch ( note.getName() ) 
			{           
				
				default:
					break;		
			}
		}
	}
}